<?php
namespace app\back\model;

use app\common\model\AssortComm;

///分类表
class AssortModel extends AssortComm
{

    ///根据分类标题获取多条数据
    public function getAssortDataByTitleArr($class_title_arr){
        return $this->where('assort_title','in',$class_title_arr)->column('assort_id,assort_title','assort_title');
    }

    ///获取不等于此id和此标题的数据条数
    public function getCountByNeqIDAndTitle($class_id,$class_title){
        return $this->where('assort_id','neq',$class_id)->where('assort_title',$class_title)->count();
    }

    ///根据分类id修改数据
    public function updateDataByID($class_id,$data){
        if(!(is_array($data))){return 0;}
        return $this->where('assort_id',$class_id)->update($data);
    }


    ///根据分类id获取一条数据
    public function getOneDataByID($data_id = 0){
        return $this->where('assort_id',$data_id)->field('assort_id,assort_title,assort_description,assort_sort,assort_status')->find();
    }

    ///创建新分类
    public function backInsertNewAssort($data = array()){
        $this->insert($data);
    }




    ///获取标题获取数据条数
    public function getCountByTitle($assort_title = ''){
        return $this->where('assort_title',$assort_title)->count();
    }

    ///获取列表页数据
    public function getIndexDataList(){
        return $this->order('assort_status desc,assort_sort desc')->field('assort_id,assort_title,assort_description,assort_sort,assort_status,create_time,update_time')->paginate(ADMIN_PAGE_LIMIT);
    }

    ///获取分类筛选项数据
    public function getSearchDataList(){
        return $this->order('assort_status desc,assort_sort desc')->field('assort_id,assort_title')->select();
    }



}